﻿/* 
* -----------------------------------------------------------------------------------
*	Component       : ModelController
*	Source file     : AcountController.cs
*	Author          : HungNguyen
*	Creation Date   : 01.29.2013
*	Description     : This file describes about functions for account of system
*	Use Case        : 
*	Includes        : 
*	Notes           : 
*	Copyright HKSoft, Inc. 2013
*	The copyright to the computer program(s) herein is the property of Prowess, Inc. 
*	The program(s) may be used and/or copied only with the written permission of HKSoft, Inc. 
*	or in accordance with the terms and conditions stipulated in the 
*	agreement/contract under which the program(s) have been supplied.
* -----------------------------------------------------------------------------------
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLBH.DataModel;
using QLBH.Model.Controller;

namespace QLBH.Model.Controller
{
    public static class AccountHandler
    {        
        private static NHANVIEN currentStaff;        
        public static NHANVIEN GetCurrentUserLogin()
        {
            return currentStaff;
        }
        public static bool Login(String userName, String pass)
        {
            try
            {
                ACOUNT acc = AcountController.GetInstance().CheckAcount(userName, pass);
                if (acc != null)
                {
                    currentStaff = NhanVienController.GetInstance().FindBy(nv => nv.NVID == acc.NHANVIENID).FirstOrDefault();
                }
                return acc != null;
            }
            catch (System.Exception ex)
            {
                //error with connection string                
                throw ex;            	
            }
            
        }
    }
}
